let oldArrayProto = Array.prototype;

export let newArrayProto = Object.create(oldArrayProto);

let methods = ['push', 'pop', 'shift', 'unshift', 'reverse', 'sort', 'splice'];

methods.forEach(method => {
    newArrayProto[method] = function (...args) {
        const result = oldArrayProto[method].call(this, ...args);

        let inserted;
        switch (method) {
            case 'splice':
                inserted = args.slice(2);

                break;
            case 'unshift':
                inserted = args;

                break;

            default:
                break;
        }

        if (inserted) {
            this.__ob__.observeArray(inserted);
        }
        return result;
    }
})